package com.mytrip.service.impl;

import java.util.List;

import com.mytrip.base.service.impl.BaseManagerImpl;
import com.mytrip.dao.NewsDAO;
import com.mytrip.model.News;
import com.mytrip.model.NewsExample;
import com.mytrip.service.NewsManager;

public class NewsManagerImpl extends BaseManagerImpl implements NewsManager{
	private NewsDAO newsDAO;

	public NewsDAO getNewsDAO(){
		return newsDAO;
	}

	public void setNewsDAO(NewsDAO newsDAO){
		this.newsDAO = newsDAO;
	}

	@Override
	public List<News> queryNews(int from, int size){
		NewsExample example = new NewsExample();
		example.setOrderByClause("publish_time desc limit " + from + "," + size);
		return newsDAO.selectByExample(example);
	}

	@Override
	public int queryNewsCnt(){
		NewsExample example = new NewsExample();
		return newsDAO.countByExample(example);
	}

	@Override
	public News queryNewsById(Integer id){
		return newsDAO.selectByPrimaryKey(id);
	}
}
